package com.letv.business.flow.PlayFlowState;

import com.ledim.app.LeDimApplication;
import com.letv.android.young.client.R;
import com.letv.business.flow.PlayFlowEvents.PlayIdleEvent;
import com.letv.business.flow.album.AlbumPlayFlowObservable;
import com.letv.core.constant.PlayConstant;
import com.letv.core.utils.LogInfo;

import org.greenrobot.eventbus.Subscribe;
import org.greenrobot.eventbus.ThreadMode;

/**
 * Created by jipengfei on 2016/12/12.
 */
public class PlayErrorState extends BasePlayState {
    @Override
    protected void injectDependencies() {
        LeDimApplication.getComponentInstance().inject(this);
    }

    @Override
    public void onStateApplied(){
        super.onStateApplied();

        LogInfo.log("sguotao", "进入PlayErrorState");

        mPlayFlow = getProvider().providPlayFlow();


        mPlayFlow.getLoadListener().requestError(mPlayFlow.getContext().getString(R.string.commit_error_info), PlayConstant.PlayErrCode.ADDRESS_OR_DATA_ACQUIRED_FAILED);
        mPlayFlow.getObserver().notifyObservers(new AlbumPlayFlowObservable.PlayErrorCodeNotify(PlayConstant.PlayErrCode.ADDRESS_OR_DATA_ACQUIRED_FAILED, true));

        //播放机状态结束,播放状态重置
        fireEvent(PlayFlowEvents.Play_Finish);

    }

    @Override
    public void onStateLeft() {
        super.onStateLeft();

    }

    @Subscribe(threadMode = ThreadMode.MAIN)
    public void onPlayIdleEvent(PlayIdleEvent playIdleEvent) {

        fireEvent(PlayFlowEvents.Play_Idle);
    }

}
